"""
CalendarCtrl
============

There are at least two issues with `CalendarCtrl`:

- The appearance of this widget can be erratic when placed inside a
`SizedPanel`, unless you use the `cal_sequential_month_selection` style.
- Accessibility for this control is poor. Once this widget receives focus,
you cannot transfer the focus to another widget by pressing the TAB key.
"""
from wxpita import *

f = SizedFrame(sizerType='horizontal') [
    SizedPanel [
        CalendarCtrl(name='cc1', style='cal_sequential_month_selection'),

        Panel [
            CalendarCtrl(name='cc2', date=wx.DateTimeFromDMY(23, 2, 1934),
                         pos=(10, 20)),
            
            CalendarCtrl(name='cc3', style='cal_show_surrounding_weeks',
                         pos=(250, 20)),
        ],
    ],
    
    TextCtrl(name='log', style='te_multiline', size=(250,-1),
             expand=True, proportion=1),
]

@f.cc1.calendar_sel_changed
@f.cc2.calendar_sel_changed
@f.cc3.calendar_sel_changed
def _(evt):
    datestr = evt.EventObject.GetDate().Format('%B %d, %Y')
    mesg = '%s: %s\n\n' % (evt.EventObject.GetName(), datestr)
    f.log.AppendText(mesg)

f.Show('CalendarCtrl Example', size=(660,440))
